package com.zx.jvm.controller;

import com.zx.jvm.bean.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author zx
 *
 * 参考:https://blog.csdn.net/javastart/article/details/50868029
 * https://blog.csdn.net/alli0968/article/details/52460008
 *
 */
@RestController
public class TestController {

    /**
     */
    @RequestMapping(path = "/hello")
    public String hello(){

        return "hello";
    }

    /**
     * jvm : -Xms20M -Xmx20M
     * -Xms:初始堆大小 -Xmx:最大堆大小 生产环境建议设置成一样，防止jvm频繁调整
     */
    @RequestMapping(path = "/heap/{value}")
    public String heap(@PathVariable int value){

        List<User> list = new ArrayList<>();
        for(int i=0;i<value;i++){
            list.add(new User("张三", 16));
        }

        return value + " : ok";
    }
}
